#ifndef __IPLUGINS_H__
#define __IPLUGINS_H__

#include <vector>
#include <string>
#include <mutex>
#include <memory>

namespace PocketSurvival
{
    class Client;
    typedef std::shared_ptr<Client> ClientPtr;

    enum class AuthDisplayType
    {
        All,                // 所有人都可以看到命令介绍
        Authority,          // 权限到达就可以查看
        OnlyTerminal,       // 只有控制台能看到
    };

    class IPlugin
    {
    public:
        class ChatObj
        {
        public:
            ClientPtr m_client;
            bool m_isTerminal;
            inline ChatObj(ClientPtr &client, bool isTerminal) : m_client(client), m_isTerminal(isTerminal) {}
            void sendMessage(const std::string &title, const std::string &message);
        };

    public:
        // 例如 10000, 就是 1.0.0   (大版本号).(副版本号).(小版本号)
        inline virtual uint32_t getVersion();
        // 插件名称
        virtual const std::string &getPluginName() = 0;
        // 插件命令介绍
        virtual const std::string &getIntroduce() = 0;
        // 插件使用的权限等级
        virtual uint32_t getUseAuthLevel() = 0;
        // 玩家查看命令介绍类型
        virtual AuthDisplayType getDisplayType() = 0;
        // 处理命令
        virtual void processCmd(ChatObj &chatObj, std::vector<std::string> &cmdDataVec) = 0;
        // 获取命令头
        inline virtual void getCmds(std::vector<std::string> &cmdVec);
        inline void process(ClientPtr &client, std::vector<std::string> &cmdDataVec, bool isTerminal);

        inline virtual void load();
        inline virtual void save();
  
    };

    inline uint32_t IPlugin::getVersion()
    {
        return 1;
    }
    inline void IPlugin::getCmds(std::vector<std::string> &cmdVec) {}
    inline void IPlugin::load() {}
    inline void IPlugin::save() {}

    inline void IPlugin::process(ClientPtr &client, std::vector<std::string> &cmdDataVec, bool isTerminal)
    {
        ChatObj chatObj(client, isTerminal);
        processCmd(chatObj, cmdDataVec);
    }

}

#endif
